class DestinosController < ApplicationController
  # GET /destinos
  # GET /destinos.json
  def index
    @destinos = Destino.all

    respond_to do |format|
      format.html # index.html.erb
      #format.json { render json: @destinos }
    end
  end

  # GET /destinos/1
  # GET /destinos/1.json
  def show
    @destino = Destino.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      #format.json { render json: @destino }
    end
  end

  # GET /destinos/new
  # GET /destinos/new.json
  def new
    @destino = Destino.new

    respond_to do |format|
      format.html # new.html.erb
      #format.json { render json: @destino }
    end
  end

  # GET /destinos/1/edit
  def edit
    @destino = Destino.find(params[:id])
  end

  # POST /destinos
  # POST /destinos.json
  def create
    @destino = Destino.new(params[:destino])

    respond_to do |format|
      if @destino.save
        format.html { redirect_to @destino, :notice=> 'Destino creado correctamente.' }
       # format.json { render json: @destino, status: :created, location: @destino }
      else
        format.html { render :action=> "new" }
        #format.json { render json: @destino.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /destinos/1
  # PUT /destinos/1.json
  def update
    @destino = Destino.find(params[:id])

    respond_to do |format|
      if @destino.update_attributes(params[:destino])
        format.html { redirect_to @destino, :notice=> 'Destino actualizado correctamente.' }
        #format.json { head :no_content }
      else
        format.html { render :action=> "edit" }
        #format.json { render json: @destino.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /destinos/1
  # DELETE /destinos/1.json
  def destroy
    @destino = Destino.find(params[:id])
    @destino.destroy

    respond_to do |format|
      format.html { redirect_to destinos_url }
      #format.json { head :no_content }
    end
  end
end
